﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MinecraftProtocol.Types;

namespace MinecraftMapViewer
{
    /// <summary>
    /// Interaction logic for Block.xaml
    /// </summary>
    public partial class Block : UserControl
    {
        public const int CxBlock = 32;

        byte _currentBlock;
        int _currentRelativeDepth;

        //double _lastYaw=-9999;

        public void SetBlock(byte block, int relativeDepth)
        {
            if (block != _currentBlock)
            {
                _currentBlock = block;

                if (block != 0)
                    TopLabel.Text = ((BlockTypes)block).ToString();
                else
                    TopLabel.Text = "";

                ToolTipService.SetToolTip(this, TopLabel.Text);
            }

            if (relativeDepth != _currentRelativeDepth)
            {
                _currentRelativeDepth = relativeDepth;

                if (block != 0)
                    BottomLabel.Text = relativeDepth.ToString();
                else
                    BottomLabel.Text = "";
                    
            }

            //if (yaw != _lastYaw)
            //{
            //    ((RotateTransform)((TransformGroup)ContainingGrid.RenderTransform).Children[0]).Angle =yaw-180;
            //    _lastYaw = yaw;
            //}
        }

        public Block()
        {
            InitializeComponent();

            TopLabel.Text = "";
            BottomLabel.Text = "";
        }
    }
}
